Skip to main content

MySQL Migration & Quality Upgrade Log

This document records the remediation and quality upgrade process performed on the MySQL documentation (Modules 10–18) after its initial migration from Notion. It serves as a comprehensive reference for future AI agents on how to structure, rewrite, and verify technical documentation improvements.


1. Environment & Paths

Key Paths

ItemPath
MySQL docs root/opt/docker-data/apps/docusaurus/site/docs/code/mysql/
Docusaurus site root/opt/docker-data/apps/docusaurus/site/
Migration knowledge/opt/docker-data/apps/docusaurus/site/docs/knowledge/docusaurus/11. Migration/
Docker container namedocusaurus
App working directory (inside container)/app

Docker Commands

# Check container status
sudo docker ps --format '{{.Names}} {{.Status}}' | grep docu

# Run Docusaurus build (verification)
sudo docker exec docusaurus sh -c "cd /app && npx docusaurus build --no-minify 2>&1 | tail -30"

# Restart container after changes
sudo docker restart docusaurus

2. Problem State (Post-Migration)

After the initial migration from Notion, the MySQL documentation Modules 10–18 exhibited two critical issues:

A. Structural Defect (Sidebar)

  • Issue: Clicking a parent category (e.g., "10. Constraints & Indexes") expanded the menu but did not show the introduction page.
  • Cause: The _category_.json files were configured as generic containers ("generated-index") instead of linking to the module's index.mdx.
  • Impact: Poor navigation experience; users couldn't easily access the module overview.

B. Content Quality Defect

  • Issue: Lesson files were extremely thin placeholders (~1.5KB / 50–70 lines).
  • Format: Repetitive, shallow structure: Introduction → Reference Table → Small Code Snippet → Pitfalls Table → Quick Reference.
  • Missing Elements: No conceptual explanations, no step-by-step walkthroughs, no real-world use cases, no exercises, no diagrams.
  • Impact: The documentation was reference-only and unsuitable for learning.

C. Modules NOT Affected

  • Modules 1–9: Already high quality from earlier, more careful migration (~7–22KB per lesson).
  • Module 19 (Backup & Recovery): Already comprehensive (~8KB / ~330 lines per lesson). Used as the quality benchmark.

3. Structural Fix (Sidebar)

We standardized the _category_.json configuration across all modules 07–18 to treat the index.mdx file as the category landing page.

File: docs/code/mysql/<module-folder>/_category_.json

Before (broken):

{
"label": "10. Constraints & Indexes",
"position": 10,
"link": {
"type": "generated-index"
}
}

After (fixed):

{
"label": "10. Constraints & Indexes",
"position": 10,
"link": {
"type": "doc",
"id": "index"
}
}

Modules fixed: 07, 08, 10, 11, 12, 13, 14, 15, 16, 17, 18 (all that had generated-index).

Outcome: Clicking the sidebar item now renders the comprehensive module overview defined in index.mdx.


4. Content Rewrite Strategy

A. Quality Standard ("Module 19 Format")

Every rewritten lesson follows this mandatory structure:

---
title: Lesson Title
description: One-line description for SEO and sidebar hover.
sidebar_position: N
---

:::tip[Learning Focus]
Use this lesson to understand **Topic** — one-sentence goal.
:::

## 1. Concept Overview ← "The Why" - theory, architecture, when to use
## 2. Basic Syntax & Rules ← "The How" - command structure, parameter tables
## 3. Step-by-Step Examples ← 2–4 progressive scenarios (Setup → Execute → Verify)
## 4. Practical Use Cases ← 3–5 real-world business scenarios
## 5. Common Mistakes ← Table: Mistake | What Happens | How to Fix
## 6. Best Practices ← Bulleted list of do's and don'ts
## 7. Hands-On Practice ← 2–3 graded exercises (Easy / Medium / Advanced)
## 8. Connection to Other Concepts ← Table linking to related topics
## 9. Visual Learning Diagram ← Mermaid diagram (flowchart, ER, sequence)
## Quick Reference ← Copy-paste-ready SQL snippets
## What's Next ← Link to next lesson

B. Target Metrics

MetricMinimumIdealMaximum
Lines per lesson200300–350470
File size (KB)69–1113
Code examples35–812
Exercises235
Mermaid diagrams112

C. Frontmatter Convention

Every lesson file uses this exact frontmatter format:

---
title: Human-Readable Lesson Title
description: One sentence describing the lesson for SEO and sidebar tooltips.
sidebar_position: 1 # Sequential within the module (1, 2, 3...)
---

Rules:

  • No id field — Docusaurus derives it from the filename.
  • No sidebar_label — uses title by default.
  • sidebar_position starts at 1 within each module folder.

D. index.mdx Convention

Every module folder contains an index.mdx that serves as the landing page:

---
title: N. Module Title
description: One-line module description.
sidebar_position: 1
---

# N. Module Title

Brief paragraph describing the module scope.

## Lessons

- [Lesson Title](./01-lesson-slug) — short description
- [Lesson Title](./02-lesson-slug) — short description

## Summary Table (optional)

| Concept | Description |
|---|---|

## What's Next

- Continue to [Next Module](../next-module/)

E. Cross-Reference Pattern

Lessons link to each other using relative paths:

<!-- Within same module -->
- [Next Lesson](./02-next-lesson)

<!-- To another module -->
- [Related Topic](../17-user-management-and-security/)

F. Consolidation Rules

When original thin files cover topics that logically belong together, consolidate:

ModuleOriginal Files (Thin)New Files (Comprehensive)
17. Security01-creating-users-and-grants.mdx (54 lines)
02-roles-authentication-and-password-policy.mdx (56 lines)
03-security-hardening-checklist.mdx (47 lines)
01-users-roles-and-privileges.mdx (357 lines)
02-security-hardening.mdx (378 lines)
18. Performance01-explain-and-query-plans.mdx (58 lines)
02-index-tuning-and-query-refactoring.mdx (59 lines)
03-server-level-optimization.mdx (54 lines)
01-query-profiling-and-explain.mdx (367 lines)
02-server-configuration-tuning.mdx (386 lines)

After consolidation: Delete old files and update index.mdx to reference new filenames.


5. Complete File Inventory

Before vs After (All Rewritten Files)

FileBefore (lines)Before (KB)After (lines)After (KB)
Module 10
01-primary-and-foreign-keys.mdx651.935613.3
02-column-and-table-constraints.mdx611.938012.5
03-index-strategy-and-maintenance.mdx651.938411.4
Module 11
01-current-date-and-time-functions.mdx551.531110.5
02-formatting-and-parsing-dates.mdx601.633810.6
03-date-arithmetic-and-difference.mdx581.633310.3
Module 12
01-creating-and-managing-views.mdx621.73479.9
02-updatable-vs-read-only-views.mdx531.535711.5
Module 13
01-stored-procedures-basics.mdx731.938011.1
02-user-defined-functions.mdx681.83399.6
03-control-flow-and-error-handling.mdx671.846712.6
Module 14
01-trigger-fundamentals.mdx601.636210.4
02-audit-and-validation-triggers.mdx551.543812.5
Module 15
01-event-scheduler-basics.mdx581.536610.3
02-recurring-maintenance-events.mdx621.737611.4
Module 16
01-acid-and-transaction-control.mdx631.737411.1
02-isolation-levels-and-locking.mdx611.634811.2
03-deadlocks-and-retry-patterns.mdx551.536311.4
Module 17 (consolidated 3→2)
01-users-roles-and-privileges.mdx35710.3
02-security-hardening.mdx37810.4
Module 18 (consolidated 3→2)
01-query-profiling-and-explain.mdx36711.3
02-server-configuration-tuning.mdx38610.9

Total: 22 final files, ~250 KB of new documentation.


6. MDX Gotchas & Common Build Errors

Future agents must be aware of these Docusaurus MDX issues:

IssueExampleFix
Unescaped < in textWHERE col > 0 AND col < 100Use &lt;WHERE col > 0 AND col &lt; 100
Unescaped < in tablesBETWEEN, >, <Use &lt;BETWEEN, >, &lt;
Unescaped { in textSET @var = {value}Wrap in backticks: `{value}`
JSX-like expressions<placeholder> outside code blocksWrap in backticks: `<placeholder>`
Comments in JSON code blocks// This is a comment inside JSONJSON doesn't support comments — remove them or use jsonc language
Angle brackets in admonitions:::tip <Title>Remove angle brackets from admonition titles
HTML tags in Mermaid labelsid[<b>Label</b>]Use quotes: id["Label"]

How to Diagnose

# Run build — error output shows exact file, line, and column
sudo docker exec docusaurus sh -c "cd /app && npx docusaurus build --no-minify 2>&1 | tail -30"

The error message includes:

  • File path: Which .mdx file failed
  • Line and column: Exact position of the problem character
  • Error type: Usually Unexpected character with the offending character

7. Execution Workflow (For Future Agents)

When performing a similar content improvement task:

Step 1: Audit

# Check file sizes to identify thin content
find /opt/docker-data/apps/docusaurus/site/docs/code/mysql/ -name '*.mdx' ! -name 'index.mdx' \
-exec sh -c 'for f; do lines=$(wc -l < "$f"); size=$(stat -c %s "$f"); printf "%-60s %4d lines %6d bytes\n" "$f" "$lines" "$size"; done' _ {} +

Files under 3KB / 100 lines are likely thin placeholders that need rewriting.

Step 2: Identify Quality Benchmark

Find a module in the same project that is already high quality. In this project:

  • Module 19 (Backup & Recovery): ~8KB per lesson
  • Module 03 (Basic SQL Operations): ~12KB per lesson

Step 3: Rewrite In-Place

  • Overwrite each .mdx file with comprehensive content.
  • Follow the standard structure (Section 4A above).
  • Preserve the sidebar_position value.

Step 4: Handle Consolidation

If multiple thin files cover overlapping topics:

  1. Create new files with better names
  2. Delete the old files
  3. Update index.mdx to reference new filenames

Step 5: Verify

  1. Check file sizes (all should be >6KB)
  2. Run Docusaurus build
  3. Fix any MDX syntax errors
  4. Confirm sidebar navigation works

8. Folder Structure Reference

docs/code/mysql/
├── _category_.json # Top-level category config
├── index.mdx # MySQL course landing page
├── 01-introduction/ # 2 lessons
├── 02-mysql-data-types/ # 4 lessons
├── 03-basic-sql-operations/ # 9 lessons
├── 04-filtering-and-conditions/ # 6 lessons
├── 05-aggregate-functions/ # 2 lessons
├── 06-joins-and-unions/ # 6 lessons
├── 07-grouping-and-filtering/ # 4 lessons
├── 08-advanced-sql-features/ # 4 lessons
├── 09-database-management/ # 5 lessons
├── 10-constraints-and-indexes/ # 3 lessons ← REWRITTEN
├── 11-date-and-time-functions/ # 3 lessons ← REWRITTEN
├── 12-views/ # 2 lessons ← REWRITTEN
├── 13-stored-procedures-and-functions/ # 3 lessons ← REWRITTEN
├── 14-triggers/ # 2 lessons ← REWRITTEN (was 3)
├── 15-event-scheduler/ # 2 lessons ← REWRITTEN (was 3)
├── 16-transactions-and-concurrency/ # 3 lessons ← REWRITTEN
├── 17-user-management-and-security/ # 2 lessons ← REWRITTEN (was 3)
├── 18-performance-optimization/ # 2 lessons ← REWRITTEN (was 3)
└── 19-backup-and-recovery/ # 4 lessons (untouched — benchmark)

Each module folder contains:

  • _category_.json — sidebar configuration
  • index.mdx — module landing/overview page
  • 01-lesson-name.mdx, 02-lesson-name.mdx, etc. — individual lessons

9. Artifacts

ArtifactPath
Task checklist/home/rezriz/.gemini/antigravity/brain/d677c38a-4d55-4e16-bb15-99e7d51c345e/task.md
Implementation plan/home/rezriz/.gemini/antigravity/brain/d677c38a-4d55-4e16-bb15-99e7d51c345e/implementation_plan.md
Walkthrough/home/rezriz/.gemini/antigravity/brain/d677c38a-4d55-4e16-bb15-99e7d51c345e/walkthrough.md
This migration log/opt/docker-data/apps/docusaurus/site/docs/knowledge/docusaurus/11. Migration/mysql-migration-and-quality-log.mdx